<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
$(document).ready(function($){
	
	// live() jquery-1.9.x remove function 
	$('#commonCodeListResult a').live('click', function(e){
		getCodeChildList($(this).attr('id'));
		e.preventDefault();
	});
	
});

function getCodeChildList(upNo){
	
	var data = JSON.stringify({'upNo' : upNo});
	//alert(data);
	$.ajax({
		contentType : 'application/json; charset=utf-8', type : 'post', dataType : 'json', async : false
		, url  : '<c:url value="/admin/common/getCodeChildList.html" />'
		, data : data
		, success : function(json){
			$('#' + upNo).next('ul').remove();
			$('<ul></ul>').append($('#code-tmpl').tmpl(json)).appendTo($('#'+upNo).parent());
	      }
	});
	
}
</script>
<script type="text/x-jquery-tmpl" id="code-tmpl" >
	<li><a id="\${codeNo }">\${codeText}</a></li>
</script>
<style type="text/css">
	#commonCodeListResult ul {list-style: none;display: list-item;}
	#commonCodeListResult li {}
</style>
</head>
<body>
<div class="row-fluid">
	<div id="commonCodeListResult">
		<ul>
			<li><a href="javascript:;" id="6">Root</a>
				<ul>
					<c:forEach items="${dataList }" var="row" varStatus="stat">
						<li><a id="${row.codeNo }">${row.codeText}</a></li>
					</c:forEach>
				</ul>
			</li>
		</ul>
	</div>
	<spring:message code="greeting" arguments="영주" text="Hi" />
</div>
</body>
</html>